NO_SELECT = []
with open('房地产开发.txt', 'r', encoding='utf-8') as file1:
    for line in file1:
        NO_SELECT.append(line.strip())
# print(NO_SELECT)

import json
import requests

header = {
	"Host": "xueqiu.com",
	"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0",
	"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
	"Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
	"Accept-Encoding": "gzip, deflate, br",
	"Connection": "keep-alive",
	"Cookie": "Hm_lvt_1db88642e346389874251b5a1eded6e3=1631239538,1631239787,1631323815,1631347604; device_id=f22a9f054403c0c6987cc97218f511d7; s=cp19vaih1o; bid=12f6cbd38037025574fa6c0b4111476f_kqaaqsph; __utma=1.1203836511.1624502332.1631328137.1631349280.18; __utmz=1.1624502332.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); xq_r_token=e4f3f6a2fe927671bf6292bb1b5e37f275b4ff1e; xq_id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ1aWQiOjg3MzY0OTk2NzcsImlzcyI6InVjIiwiZXhwIjoxNjMzNTc0MjkwLCJjdG0iOjE2MzA5ODIyOTA1NjYsImNpZCI6ImQ5ZDBuNEFadXAifQ.CE-S3i5GaoRFVDUCYZjURbMkxD3egmwoLLXA-lg17IoJq1nNOoO8FdRJKoZAmhIMudcFuWPRqfOdaItNF6Pi1uuc9TLiAhIqnPYX7YsfMMRYgpb93BQXQYIzHlfe5gGVMTx6negyOwIdznvNZlPQDMC2TcglnrDIfBSP6lFHgz-XNmYiiAfloFu56xz-A1twnNQNGvfS1ePmZA1ir3hG9VsH257W3HuHIZ_32gO1-wxc0PP9gLfKE7DNnrVut2NH2t5f0N5uOmT2SwI0LYW5txDsEkzloNTCGa1sWq0z1s6DHZ7qO7rTkDj5Bsr2Rsekrf-Eik5mu2_Sz5XRFxqMpA; u=8736499677; xq_is_login=1; xq_a_token=b0d08e39a53365bc934012b1a69be0be168da130; xqat=b0d08e39a53365bc934012b1a69be0be168da130; Hm_lpvt_1db88642e346389874251b5a1eded6e3=1631349455; snbim_minify=true; acw_sc__v2=613c6a1f54f990fff769ef6237f6e9f7667cf442; __utmc=1; acw_tc=2760829016313512563434388e8568680caffe0ba88d054872bfe1442c50f1",
	"Upgrade-Insecure-Requests": "1",
	"Sec-Fetch-Dest": "document",
	"Sec-Fetch-Mode": "navigate",
	"Sec-Fetch-Site": "none",
	"Sec-Fetch-User": "?1",
	"Pragma": "no-cache",
	"Cache-Control": "no-cache"
}


def radom_sleep():
    import time
    import random
    time.sleep(random.random() * 10 + 5)


def local_time():
    import time
    return time.strftime('%Y-%m-%d', time.localtime(time.time()))

def get_field():
    url = "https://xueqiu.com/service/screener/screen?category=CN&exchange=sh_sz&areacode=&indcode=&order_by=pettm&order=asc&page=1&size=200&only_count=0&current=&pct=&pettm=0_8.5&_=1631353479673"
    resp = requests.get(url, timeout=30, headers=header)
    res = str(resp.text)
    data = json.loads(res)
    print(res)
    one_page = data["data"]["list"]
    for one in one_page:
        need_name = str(one['name'])
        if need_name not in NO_SELECT and not need_name.__contains__('行') and not need_name.__contains__('ST'):
            print(need_name)

if __name__ == '__main__':
    get_field()